package com.fsnbigdata.web;

import com.fsnbigdata.domain.Log;
import com.fsnbigdata.domain.ZhEcologyNav;
import com.fsnbigdata.service.api.LogService;
import com.fsnbigdata.util.DateCuteUtil;
import com.fsnbigdata.util.DateUtil;
import com.fsnbigdata.util.ReflectUtil;
import com.fsnbigdata.util.SortTools;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.*;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by zq on 2019/3/26.
 */
@RestController
@RequestMapping("/api/log")
public class LogController {

    @Autowired
    private LogService logService;

    SimpleDateFormat fmt = new SimpleDateFormat("yyyy/MM/dd");

    /**
     * 详情
     * @param request
     * @return
     */
    @GetMapping("findOne")
    public Log findById(HttpServletRequest request){
        Long id = Long.parseLong( request.getParameter( "id" ) );
        return logService.findById( id );
    }

    /**
     * 删除
     * @param request
     */
    @GetMapping("delete")
    @PreAuthorize("hasRole('DB_LOG')")
    public ResponseEntity<?> delete(HttpServletRequest request) throws Exception {
        Long id = Long.parseLong( request.getParameter( "id" ));
        logService.deleteOne(id);
        return ResponseEntity.ok().build();
    }

    /**
     * 模糊分页查询
     */
    @GetMapping("pageList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", defaultValue = "0", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "size", defaultValue = "20", dataType = "int", paramType = "query")
    })
    @PreAuthorize("hasRole('DB_LOG')")
    public Page<Log> getPageList(HttpServletRequest request, Pageable pageable, Authentication authentication) {
        String status = request.getParameter("status");//关键字搜索
        String startTime = request.getParameter("startTime");
        String endTime = request.getParameter("endTime");
        String genre = request.getParameter("genre");
        String description = request.getParameter("description");
        String creator = null;
        Pageable pageable1 = new PageRequest( pageable.getPageNumber(),pageable.getPageSize(), SortTools.basicSort( "desc","createTime" ));
        List<String> authorities = authentication.getAuthorities().stream().map(it -> it.getAuthority()).collect(Collectors.toList());
        if (!authorities.contains("ROLE_USER_ADMIN")) {
            creator = authentication.getName();
        }
        Date date = DateUtil.getEndOfDay(new Date());
        Calendar c = Calendar.getInstance();
        if (!(status == null || "".equals(status) || "0".equals(status))) {
            switch (status) {
                //近一周
                case "1":
                    c.setTime(date);
                    c.add(Calendar.DATE, - 7);
                    startTime = c.getTime().getTime()+"";
                    endTime = date.getTime()+"";
                    break;
                //近一月
                case "2":
                    c.setTime(date);
                    c.add(Calendar.MONTH, - 1);
                    startTime = c.getTime().getTime()+"";
                    endTime = date.getTime()+"";
                    break;
                //近三月
                case "3":
                    c.setTime(date);
                    c.add(Calendar.MONTH, - 3);
                    startTime = c.getTime().getTime()+"";
                    endTime = date.getTime()+"";
                    break;
                //近半年
                case "4":
                    c.setTime(date);
                    c.add(Calendar.MONTH, - 6);
                    startTime = c.getTime().getTime()+"";
                    endTime = date.getTime()+"";
                    break;
                //近一年
                case "5":
                    c.setTime(date);
                    c.add(Calendar.YEAR, - 1);
                    startTime = c.getTime().getTime()+"";
                    endTime = date.getTime()+"";
                    break;
            }
        }
        Page page = logService.findByPageAndSize(startTime, endTime, creator, genre,description,pageable1);
        return page;
    }

    @GetMapping("chartCount")
    @PreAuthorize("hasRole('DB_LOG')")
    public List chartCount(HttpServletRequest request, Pageable pageable, Authentication authentication){
        String status = request.getParameter("status");//关键字搜索
        String startTime = request.getParameter("startTime");
        String endTime = request.getParameter("endTime");
        String description = request.getParameter("description");
        String creator = null;
        Pageable pageable1 = new PageRequest( pageable.getPageNumber(),pageable.getPageSize(), SortTools.basicSort( "desc","createTime" ));
        List<String> authorities = authentication.getAuthorities().stream().map(it -> it.getAuthority()).collect(Collectors.toList());
        if (!authorities.contains("ROLE_USER_ADMIN")) {
            creator = authentication.getName();
        }
        return logService.chartCount(status,startTime,endTime,description,creator);
    }

    /**
     * cqz
     * 近7天每天3种类型的次数
     * @return
     */
    @PostMapping("findThreeByWeek")
    public Map findThreeByWeek(){
        Map map = new HashMap();
        Calendar calendar = Calendar.getInstance();
        long nowTome = calendar.getTime().getTime();
        // 7天前日期
        Date bw = DateCuteUtil.getTimeByWeek(calendar,-7);
        String SevenDay = fmt.format(bw);
        long beforeWeek = bw.getTime();
        List<Log> Z_log0 = logService.findAllByBeforeTime(nowTome,beforeWeek,"0");
        List<Log> Z_log1 = logService.findAllByBeforeTime(nowTome,beforeWeek,"1");
        List<Log> Z_log2 = logService.findAllByBeforeTime(nowTome,beforeWeek,"2");

        // 1天前日期    6
        Date oneDay1 = DateCuteUtil.getTimeByWeek(calendar,-1);
        Date oneDay = DateCuteUtil.lastTime(oneDay1);
        // 2天前日期    5
        Date twoDay1 = DateCuteUtil.getTimeByWeek(calendar,-2);
        Date twoDay = DateCuteUtil.lastTime(twoDay1);
        // 3天前日期    4
        Date threeDay1 = DateCuteUtil.getTimeByWeek(calendar,-3);
        Date threeDay = DateCuteUtil.lastTime(threeDay1);
        // 4天前日期    3
        Date fourDay1 = DateCuteUtil.getTimeByWeek(calendar,-4);
        Date fourDay = DateCuteUtil.lastTime(fourDay1);
        // 5天前日期   2
        Date fiveDay1 = DateCuteUtil.getTimeByWeek(calendar,-5);
        Date fiveDay = DateCuteUtil.lastTime(fiveDay1);
        // 6天前日期   1
        Date sixDay1 = DateCuteUtil.getTimeByWeek(calendar,-6);
        Date sixDay = DateCuteUtil.lastTime(sixDay1);

        // 第一段
        List<Log> one_log0 = logService.findAllByBeforeTime(sixDay.getTime(),beforeWeek,"0");
        List<Log> one_log1 = logService.findAllByBeforeTime(sixDay.getTime(),beforeWeek,"1");
        List<Log> one_log2 = logService.findAllByBeforeTime(sixDay.getTime(),beforeWeek,"2");
        String one_flag = fmt.format(sixDay);
        List list1 = new ArrayList();
        list1.add(one_log0.size());
        list1.add(one_log1.size());
        list1.add(one_log2.size());

        // 第二段
        List<Log> two_log0 = logService.findAllByBeforeTime(fiveDay.getTime(),sixDay.getTime(),"0");
        List<Log> two_log1 = logService.findAllByBeforeTime(fiveDay.getTime(),sixDay.getTime(),"1");
        List<Log> two_log2 = logService.findAllByBeforeTime(fiveDay.getTime(),sixDay.getTime(),"2");
        String two_flag = fmt.format(fiveDay);
        List list2 = new ArrayList();
        list2.add(two_log0.size());
        list2.add(two_log1.size());
        list2.add(two_log2.size());

        // 第三段
        List<Log> three_log0 = logService.findAllByBeforeTime(fourDay.getTime(),fiveDay.getTime(),"0");
        List<Log> three_log1 = logService.findAllByBeforeTime(fourDay.getTime(),fiveDay.getTime(),"1");
        List<Log> three_log2 = logService.findAllByBeforeTime(fourDay.getTime(),fiveDay.getTime(),"2");
        String three_flag = fmt.format(fourDay);
        List list3 = new ArrayList();
        list3.add(three_log0.size());
        list3.add(three_log1.size());
        list3.add(three_log2.size());

        // 第四段
        List<Log> four_log0 = logService.findAllByBeforeTime(threeDay.getTime(),fourDay.getTime(),"0");
        List<Log> four_log1 = logService.findAllByBeforeTime(threeDay.getTime(),fourDay.getTime(),"1");
        List<Log> four_log2 = logService.findAllByBeforeTime(threeDay.getTime(),fourDay.getTime(),"2");
        String four_flag = fmt.format(threeDay);
        List list4 = new ArrayList();
        list4.add(four_log0.size());
        list4.add(four_log1.size());
        list4.add(four_log2.size());

        // 第五段
        List<Log> five_log0 = logService.findAllByBeforeTime(twoDay.getTime(),threeDay.getTime(),"0");
        List<Log> five_log1 = logService.findAllByBeforeTime(twoDay.getTime(),threeDay.getTime(),"1");
        List<Log> five_log2 = logService.findAllByBeforeTime(twoDay.getTime(),threeDay.getTime(),"2");
        String five_flag = fmt.format(twoDay);
        List list5 = new ArrayList();
        list5.add(five_log0.size());
        list5.add(five_log1.size());
        list5.add(five_log2.size());

        // 第六段
        List<Log> six_log0 = logService.findAllByBeforeTime(oneDay.getTime(),twoDay.getTime(),"0");
        List<Log> six_log1 = logService.findAllByBeforeTime(oneDay.getTime(),twoDay.getTime(),"1");
        List<Log> six_log2 = logService.findAllByBeforeTime(oneDay.getTime(),twoDay.getTime(),"2");
        String six_flag = fmt.format(oneDay);
        List list6 = new ArrayList();
        list6.add(six_log0.size());
        list6.add(six_log1.size());
        list6.add(six_log2.size());

        // 第七段
        List<Log> seven_log0 = logService.findAllByBeforeTime(nowTome,oneDay.getTime(),"0");
        List<Log> seven_log1 = logService.findAllByBeforeTime(nowTome,oneDay.getTime(),"1");
        List<Log> seven_log2 = logService.findAllByBeforeTime(nowTome,oneDay.getTime(),"2");
        String seven_flag = fmt.format(calendar.getTime());
        List list7 = new ArrayList();
        list7.add(seven_log0.size());
        list7.add(seven_log1.size());
        list7.add(seven_log2.size());

        map.put("1",one_flag);
        map.put("2",two_flag);
        map.put("3",three_flag);
        map.put("4",four_flag);
        map.put("5",five_flag);
        map.put("6",six_flag);
        map.put("7",seven_flag);
        map.put("8",list1);
        map.put("9",list2);
        map.put("10",list3);
        map.put("11",list4);
        map.put("12",list5);
        map.put("13",list6);
        map.put("14",list7);

        return map;
    }

    /**
     * cqz
     * 近7天每天某一种的次数
     * @param genre
     * @return
     */
    @PostMapping("findOneByWeek")
    public Map findOneByWeek(@RequestParam("genre") String genre){
        Map map = new HashMap();
        Calendar calendar = Calendar.getInstance();
        long nowTome = calendar.getTime().getTime();
        // 7天前日期
        Date bw = DateCuteUtil.getTimeByWeek(calendar,-7);
        String SevenDay = fmt.format(bw);
        long beforeWeek = bw.getTime();
        List<Log> Z_log0 = logService.findAllByBeforeTime(nowTome,beforeWeek,genre);

        // 1天前日期    6
        Date oneDay1 = DateCuteUtil.getTimeByWeek(calendar,-1);
        Date oneDay = DateCuteUtil.lastTime(oneDay1);
        // 2天前日期    5
        Date twoDay1 = DateCuteUtil.getTimeByWeek(calendar,-2);
        Date twoDay = DateCuteUtil.lastTime(twoDay1);
        // 3天前日期    4
        Date threeDay1 = DateCuteUtil.getTimeByWeek(calendar,-3);
        Date threeDay = DateCuteUtil.lastTime(threeDay1);
        // 4天前日期    3
        Date fourDay1 = DateCuteUtil.getTimeByWeek(calendar,-4);
        Date fourDay = DateCuteUtil.lastTime(fourDay1);
        // 5天前日期   2
        Date fiveDay1 = DateCuteUtil.getTimeByWeek(calendar,-5);
        Date fiveDay = DateCuteUtil.lastTime(fiveDay1);
        // 6天前日期   1
        Date sixDay1 = DateCuteUtil.getTimeByWeek(calendar,-6);
        Date sixDay = DateCuteUtil.lastTime(sixDay1);

        // 第一段
        List<Log> one_log0 = logService.findAllByBeforeTime(sixDay.getTime(),beforeWeek,genre);
        String one_flag = fmt.format(sixDay);

        // 第二段
        List<Log> two_log0 = logService.findAllByBeforeTime(fiveDay.getTime(),sixDay.getTime(),genre);
        String two_flag = fmt.format(fiveDay);

        // 第三段
        List<Log> three_log0 = logService.findAllByBeforeTime(fourDay.getTime(),fiveDay.getTime(),genre);;
        String three_flag = fmt.format(fourDay);

        // 第四段
        List<Log> four_log0 = logService.findAllByBeforeTime(threeDay.getTime(),fourDay.getTime(),genre);
        String four_flag = fmt.format(threeDay);

        // 第五段
        List<Log> five_log0 = logService.findAllByBeforeTime(twoDay.getTime(),threeDay.getTime(),genre);
        String five_flag = fmt.format(twoDay);

        // 第六段
        List<Log> six_log0 = logService.findAllByBeforeTime(oneDay.getTime(),twoDay.getTime(),genre);
        String six_flag = fmt.format(oneDay);

        // 第七段
        List<Log> seven_log0 = logService.findAllByBeforeTime(nowTome,oneDay.getTime(),genre);
        String seven_flag = fmt.format(calendar.getTime());

        map.put("1",one_flag);
        map.put("2",two_flag);
        map.put("3",three_flag);
        map.put("4",four_flag);
        map.put("5",five_flag);
        map.put("6",six_flag);
        map.put("7",seven_flag);
        map.put("8",one_log0.size());
        map.put("9",two_log0.size());
        map.put("10",three_log0.size());
        map.put("11",four_log0.size());
        map.put("12",five_log0.size());
        map.put("13",six_log0.size());
        map.put("14",seven_log0.size());

        return map;
    }

    /**
     * 近1个月内某一类型请求的次数
     * @param genre
     * @return
     */
    @PostMapping("findOneByOneMonth")
    public Map findOneByOneMonth(@RequestParam("genre") String genre){
        Map map = new HashMap();
        Calendar calendar = Calendar.getInstance();
        long nowTome = calendar.getTime().getTime();

        // 1周前日期
        Date OneWeek1 = DateCuteUtil.getTimeByWeek(calendar,-7);
        Date OneWeek = DateCuteUtil.lastTime(OneWeek1);
        // 2周前日期
        Date TwoWeek1 = DateCuteUtil.getTimeByWeek(calendar,-14);
        Date TwoWeek = DateCuteUtil.lastTime(TwoWeek1);
        // 3周前日期
        Date ThreeWeek1 = DateCuteUtil.getTimeByWeek(calendar,-21);
        Date ThreeWeek = DateCuteUtil.lastTime(ThreeWeek1);
        // 4周前日期
        Date FourWeek1 = DateCuteUtil.getTimeByWeek(calendar,-28);
        Date FourWeek = DateCuteUtil.lastTime(FourWeek1);

        // 第一段
        String one_flag = fmt.format(FourWeek);
        List<Log> one_log = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),genre);
        // 第二段
        String two_flag = fmt.format(ThreeWeek);
        List<Log> two_log = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),genre);
        // 第三段
        String three_flag = fmt.format(TwoWeek);
        List<Log> three_log = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),genre);
        // 第四段
        String four_flag = fmt.format(calendar.getTime());
        List<Log> four_log = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),genre);

        map.put("1",one_flag);
        map.put("2",two_flag);
        map.put("3",three_flag);
        map.put("4",four_flag);
        map.put("5",one_log.size());
        map.put("6",two_log.size());
        map.put("7",three_log.size());
        map.put("8",four_log.size());

        return map;
    }

    /**
     * 近1个月内3种访问次数统计
     * @return
     */
    @PostMapping("findThreeByOneMonth")
    public Map findThreeByOneMonth(){
        Map map = new HashMap();
        Calendar calendar = Calendar.getInstance();
        long nowTome = calendar.getTime().getTime();

        // 1周前日期
        Date OneWeek1 = DateCuteUtil.getTimeByWeek(calendar,-7);
        Date OneWeek = DateCuteUtil.lastTime(OneWeek1);
        // 2周前日期
        Date TwoWeek1 = DateCuteUtil.getTimeByWeek(calendar,-14);
        Date TwoWeek = DateCuteUtil.lastTime(TwoWeek1);
        // 3周前日期
        Date ThreeWeek1 = DateCuteUtil.getTimeByWeek(calendar,-21);
        Date ThreeWeek = DateCuteUtil.lastTime(ThreeWeek1);
        // 4周前日期
        Date FourWeek1 = DateCuteUtil.getTimeByWeek(calendar,-28);
        Date FourWeek = DateCuteUtil.lastTime(FourWeek1);

        // 第一段
        String one_flag = fmt.format(FourWeek);
        List<Log> one_log0 = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),"0");
        List<Log> one_log1 = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),"1");
        List<Log> one_log2 = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),"2");
        List list1 = new ArrayList();
        list1.add(one_log0.size());
        list1.add(one_log1.size());
        list1.add(one_log2.size());
        // 第二段
        String two_flag = fmt.format(ThreeWeek);
        List<Log> two_log0 = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),"0");
        List<Log> two_log1 = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),"1");
        List<Log> two_log2 = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),"2");
        List list2 = new ArrayList();
        list2.add(two_log0.size());
        list2.add(two_log1.size());
        list2.add(two_log2.size());
        // 第三段
        String three_flag = fmt.format(TwoWeek);
        List<Log> three_log0 = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),"0");
        List<Log> three_log1 = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),"1");
        List<Log> three_log2 = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),"2");
        List list3 = new ArrayList();
        list3.add(three_log0.size());
        list3.add(three_log1.size());
        list3.add(three_log2.size());
        // 第四段
        String four_flag = fmt.format(calendar.getTime());
        List<Log> four_log0 = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),"0");
        List<Log> four_log1 = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),"1");
        List<Log> four_log2 = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),"2");
        List list4 = new ArrayList();
        list4.add(four_log0.size());
        list4.add(four_log1.size());
        list4.add(four_log2.size());

        map.put("1",one_flag);
        map.put("2",two_flag);
        map.put("3",three_flag);
        map.put("4",four_flag);
        map.put("5",list1);
        map.put("6",list2);
        map.put("7",list3);
        map.put("8",list4);

        return map;
    }

    /**
     * 近3个月内某一请求的次数统计
     * @param genre
     * @return
     */
    @PostMapping("findOneByThreeMonth")
    public Map findOneByThreeMonth(@RequestParam("genre") String genre){
        Map map = new HashMap();
        Calendar calendar = Calendar.getInstance();
        long nowTome = calendar.getTime().getTime();

        // 1周前日期
        Date OneWeek1 = DateCuteUtil.getTimeByWeek(calendar,-7);
        Date OneWeek = DateCuteUtil.lastTime(OneWeek1);
        // 2周前日期
        Date TwoWeek1 = DateCuteUtil.getTimeByWeek(calendar,-14);
        Date TwoWeek = DateCuteUtil.lastTime(TwoWeek1);
        // 3周前日期
        Date ThreeWeek1 = DateCuteUtil.getTimeByWeek(calendar,-21);
        Date ThreeWeek = DateCuteUtil.lastTime(ThreeWeek1);
        // 4周前日期
        Date FourWeek1 = DateCuteUtil.getTimeByWeek(calendar,-28);
        Date FourWeek = DateCuteUtil.lastTime(FourWeek1);
        // 5周前日期
        Date FiveWeek1 = DateCuteUtil.getTimeByWeek(calendar,-35);
        Date FiveWeek = DateCuteUtil.lastTime(FiveWeek1);
        // 6周前日期
        Date SixWeek1 = DateCuteUtil.getTimeByWeek(calendar,-42);
        Date SixWeek = DateCuteUtil.lastTime(SixWeek1);
        // 7周前日期
        Date SevenWeek1 = DateCuteUtil.getTimeByWeek(calendar,-49);
        Date SevenWeek = DateCuteUtil.lastTime(SevenWeek1);
        // 8周前日期
        Date EightWeek1 = DateCuteUtil.getTimeByWeek(calendar,-56);
        Date EightWeek = DateCuteUtil.lastTime(EightWeek1);
        // 9周前日期
        Date NineWeek1 = DateCuteUtil.getTimeByWeek(calendar,-63);
        Date NineWeek = DateCuteUtil.lastTime(NineWeek1);
        // 10周前日期
        Date TenWeek1 = DateCuteUtil.getTimeByWeek(calendar,-70);
        Date TenWeek = DateCuteUtil.lastTime(TenWeek1);
        // 11周前日期
        Date ElevenWeek1 = DateCuteUtil.getTimeByWeek(calendar,-77);
        Date ElevenWeek = DateCuteUtil.lastTime(ElevenWeek1);
        // 12周前日期
        Date TwelveWeek1 = DateCuteUtil.getTimeByWeek(calendar,-84);
        Date TwelveWeek = DateCuteUtil.lastTime(TwelveWeek1);

        // 第一段
        String one_flag = fmt.format(TwelveWeek);
        List<Log> one_log = logService.findAllByBeforeTime(ElevenWeek.getTime(),TwelveWeek.getTime(),genre);
        // 第二段
        String two_flag = fmt.format(ElevenWeek);
        List<Log> two_log = logService.findAllByBeforeTime(TenWeek.getTime(),ElevenWeek.getTime(),genre);
        // 第三段
        String three_flag = fmt.format(TenWeek);
        List<Log> three_log = logService.findAllByBeforeTime(NineWeek.getTime(),TenWeek.getTime(),genre);
        // 第四段
        String four_flag = fmt.format(NineWeek);
        List<Log> four_log = logService.findAllByBeforeTime(EightWeek.getTime(),NineWeek.getTime(),genre);
        // 第五段
        String five_flag = fmt.format(EightWeek);
        List<Log> five_log = logService.findAllByBeforeTime(SevenWeek.getTime(),EightWeek.getTime(),genre);
        // 第六段
        String six_flag = fmt.format(SevenWeek);
        List<Log> six_log = logService.findAllByBeforeTime(SixWeek.getTime(),SevenWeek.getTime(),genre);
        // 第七段
        String seven_flag = fmt.format(SixWeek);
        List<Log> seven_log = logService.findAllByBeforeTime(FiveWeek.getTime(),SixWeek.getTime(),genre);
        // 第八段
        String eight_flag = fmt.format(FiveWeek);
        List<Log> eight_log = logService.findAllByBeforeTime(FourWeek.getTime(),FiveWeek.getTime(),genre);
        // 第九段
        String nine_flag = fmt.format(FourWeek);
        List<Log> nine_log = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),genre);
        // 第十段
        String ten_flag = fmt.format(ThreeWeek);
        List<Log> ten_log = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),genre);
        // 第十一段
        String eleven_flag = fmt.format(TwoWeek);
        List<Log> eleven_log = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),genre);
        // 第十二段
        String twelve_flag = fmt.format(OneWeek);
        List<Log> twelve_log = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),genre);

        map.put("1",one_flag);
        map.put("2",two_flag);
        map.put("3",three_flag);
        map.put("4",four_flag);
        map.put("5",five_flag);
        map.put("6",six_flag);
        map.put("7",seven_flag);
        map.put("8",eight_flag);
        map.put("9",nine_flag);
        map.put("10",ten_flag);
        map.put("11",eleven_flag);
        map.put("12",twelve_flag);
        map.put("13",one_log.size());
        map.put("14",two_log.size());
        map.put("15",three_log.size());
        map.put("16",four_log.size());
        map.put("17",five_log.size());
        map.put("18",six_log.size());
        map.put("19",seven_log.size());
        map.put("20",eight_log.size());
        map.put("21",nine_log.size());
        map.put("22",ten_log.size());
        map.put("23",eleven_log.size());
        map.put("24",twelve_log.size());

        return map;
    }

    /**
     * 近3个月内3种请求的次数统计
     * @return
     */
    @PostMapping("findThreeByThreeMonth")
    public Map findThreeByThreeMonth(){
        Map map = new HashMap();
        Calendar calendar = Calendar.getInstance();
        long nowTome = calendar.getTime().getTime();

        // 1周前日期
        Date OneWeek1 = DateCuteUtil.getTimeByWeek(calendar,-7);
        Date OneWeek = DateCuteUtil.lastTime(OneWeek1);
        // 2周前日期
        Date TwoWeek1 = DateCuteUtil.getTimeByWeek(calendar,-14);
        Date TwoWeek = DateCuteUtil.lastTime(TwoWeek1);
        // 3周前日期
        Date ThreeWeek1 = DateCuteUtil.getTimeByWeek(calendar,-21);
        Date ThreeWeek = DateCuteUtil.lastTime(ThreeWeek1);
        // 4周前日期
        Date FourWeek1 = DateCuteUtil.getTimeByWeek(calendar,-28);
        Date FourWeek = DateCuteUtil.lastTime(FourWeek1);
        // 5周前日期
        Date FiveWeek1 = DateCuteUtil.getTimeByWeek(calendar,-35);
        Date FiveWeek = DateCuteUtil.lastTime(FiveWeek1);
        // 6周前日期
        Date SixWeek1 = DateCuteUtil.getTimeByWeek(calendar,-42);
        Date SixWeek = DateCuteUtil.lastTime(SixWeek1);
        // 7周前日期
        Date SevenWeek1 = DateCuteUtil.getTimeByWeek(calendar,-49);
        Date SevenWeek = DateCuteUtil.lastTime(SevenWeek1);
        // 8周前日期
        Date EightWeek1 = DateCuteUtil.getTimeByWeek(calendar,-56);
        Date EightWeek = DateCuteUtil.lastTime(EightWeek1);
        // 9周前日期
        Date NineWeek1 = DateCuteUtil.getTimeByWeek(calendar,-63);
        Date NineWeek = DateCuteUtil.lastTime(NineWeek1);
        // 10周前日期
        Date TenWeek1 = DateCuteUtil.getTimeByWeek(calendar,-70);
        Date TenWeek = DateCuteUtil.lastTime(TenWeek1);
        // 11周前日期
        Date ElevenWeek1 = DateCuteUtil.getTimeByWeek(calendar,-77);
        Date ElevenWeek = DateCuteUtil.lastTime(ElevenWeek1);
        // 12周前日期
        Date TwelveWeek1 = DateCuteUtil.getTimeByWeek(calendar,-84);
        Date TwelveWeek = DateCuteUtil.lastTime(TwelveWeek1);

        // 第一段
        String one_flag = fmt.format(TwelveWeek);
        List<Log> one_log0 = logService.findAllByBeforeTime(ElevenWeek.getTime(),TwelveWeek.getTime(),"0");
        List<Log> one_log1 = logService.findAllByBeforeTime(ElevenWeek.getTime(),TwelveWeek.getTime(),"1");
        List<Log> one_log2 = logService.findAllByBeforeTime(ElevenWeek.getTime(),TwelveWeek.getTime(),"2");
        List list1 = new ArrayList();
        list1.add(one_log0.size());
        list1.add(one_log1.size());
        list1.add(one_log2.size());
        // 第二段
        String two_flag = fmt.format(ElevenWeek);
        List<Log> two_log0 = logService.findAllByBeforeTime(TenWeek.getTime(),ElevenWeek.getTime(),"0");
        List<Log> two_log1 = logService.findAllByBeforeTime(TenWeek.getTime(),ElevenWeek.getTime(),"1");
        List<Log> two_log2 = logService.findAllByBeforeTime(TenWeek.getTime(),ElevenWeek.getTime(),"2");
        List list2 = new ArrayList();
        list2.add(two_log0.size());
        list2.add(two_log1.size());
        list2.add(two_log2.size());
        // 第三段
        String three_flag = fmt.format(TenWeek);
        List<Log> three_log0 = logService.findAllByBeforeTime(NineWeek.getTime(),TenWeek.getTime(),"0");
        List<Log> three_log1 = logService.findAllByBeforeTime(NineWeek.getTime(),TenWeek.getTime(),"1");
        List<Log> three_log2 = logService.findAllByBeforeTime(NineWeek.getTime(),TenWeek.getTime(),"2");
        List list3 = new ArrayList();
        list3.add(three_log0.size());
        list3.add(three_log1.size());
        list3.add(three_log2.size());
        // 第四段
        String four_flag = fmt.format(NineWeek);
        List<Log> four_log0 = logService.findAllByBeforeTime(EightWeek.getTime(),NineWeek.getTime(),"0");
        List<Log> four_log1 = logService.findAllByBeforeTime(EightWeek.getTime(),NineWeek.getTime(),"1");
        List<Log> four_log2 = logService.findAllByBeforeTime(EightWeek.getTime(),NineWeek.getTime(),"2");
        List list4 = new ArrayList();
        list4.add(four_log0.size());
        list4.add(four_log1.size());
        list4.add(four_log2.size());
        // 第五段
        String five_flag = fmt.format(EightWeek);
        List<Log> five_log0 = logService.findAllByBeforeTime(SevenWeek.getTime(),EightWeek.getTime(),"0");
        List<Log> five_log1 = logService.findAllByBeforeTime(SevenWeek.getTime(),EightWeek.getTime(),"1");
        List<Log> five_log2 = logService.findAllByBeforeTime(SevenWeek.getTime(),EightWeek.getTime(),"2");
        List list5 = new ArrayList();
        list5.add(five_log0.size());
        list5.add(five_log1.size());
        list5.add(five_log2.size());
        // 第六段
        String six_flag = fmt.format(SevenWeek);
        List<Log> six_log0 = logService.findAllByBeforeTime(SixWeek.getTime(),SevenWeek.getTime(),"0");
        List<Log> six_log1 = logService.findAllByBeforeTime(SixWeek.getTime(),SevenWeek.getTime(),"1");
        List<Log> six_log2 = logService.findAllByBeforeTime(SixWeek.getTime(),SevenWeek.getTime(),"2");
        List list6 = new ArrayList();
        list6.add(six_log0.size());
        list6.add(six_log1.size());
        list6.add(six_log2.size());
        // 第七段
        String seven_flag = fmt.format(SixWeek);
        List<Log> seven_log0 = logService.findAllByBeforeTime(FiveWeek.getTime(),SixWeek.getTime(),"0");
        List<Log> seven_log1 = logService.findAllByBeforeTime(FiveWeek.getTime(),SixWeek.getTime(),"1");
        List<Log> seven_log2 = logService.findAllByBeforeTime(FiveWeek.getTime(),SixWeek.getTime(),"2");
        List list7 = new ArrayList();
        list7.add(seven_log0.size());
        list7.add(seven_log1.size());
        list7.add(seven_log2.size());
        // 第八段
        String eight_flag = fmt.format(FiveWeek);
        List<Log> eight_log0 = logService.findAllByBeforeTime(FourWeek.getTime(),FiveWeek.getTime(),"0");
        List<Log> eight_log1 = logService.findAllByBeforeTime(FourWeek.getTime(),FiveWeek.getTime(),"1");
        List<Log> eight_log2 = logService.findAllByBeforeTime(FourWeek.getTime(),FiveWeek.getTime(),"2");
        List list8 = new ArrayList();
        list8.add(eight_log0.size());
        list8.add(eight_log1.size());
        list8.add(eight_log2.size());
        // 第九段
        String nine_flag = fmt.format(FourWeek);
        List<Log> nine_log0 = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),"0");
        List<Log> nine_log1 = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),"1");
        List<Log> nine_log2 = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),"2");
        List list9 = new ArrayList();
        list9.add(nine_log0.size());
        list9.add(nine_log1.size());
        list9.add(nine_log2.size());
        // 第十段
        String ten_flag = fmt.format(ThreeWeek);
        List<Log> ten_log0 = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),"0");
        List<Log> ten_log1 = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),"1");
        List<Log> ten_log2 = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),"2");
        List list10 = new ArrayList();
        list10.add(ten_log0.size());
        list10.add(ten_log1.size());
        list10.add(ten_log2.size());
        // 第十一段
        String eleven_flag = fmt.format(TwoWeek);
        List<Log> eleven_log0 = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),"0");
        List<Log> eleven_log1 = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),"1");
        List<Log> eleven_log2 = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),"2");
        List list11 = new ArrayList();
        list11.add(eleven_log0.size());
        list11.add(eleven_log1.size());
        list11.add(eleven_log2.size());
        // 第十二段
        String twelve_flag = fmt.format(OneWeek);
        List<Log> twelve_log0 = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),"0");
        List<Log> twelve_log1 = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),"1");
        List<Log> twelve_log2 = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),"2");
        List list12 = new ArrayList();
        list12.add(twelve_log0.size());
        list12.add(twelve_log1.size());
        list12.add(twelve_log2.size());

        map.put("1",one_flag);
        map.put("2",two_flag);
        map.put("3",three_flag);
        map.put("4",four_flag);
        map.put("5",five_flag);
        map.put("6",six_flag);
        map.put("7",seven_flag);
        map.put("8",eight_flag);
        map.put("9",nine_flag);
        map.put("10",ten_flag);
        map.put("11",eleven_flag);
        map.put("12",twelve_flag);
        map.put("13",list1);
        map.put("14",list2);
        map.put("15",list3);
        map.put("16",list4);
        map.put("17",list5);
        map.put("18",list6);
        map.put("19",list7);
        map.put("20",list8);
        map.put("21",list9);
        map.put("22",list10);
        map.put("23",list11);
        map.put("24",list12);

        return map;
    }

    /**
     * 近6个月内某一请求的次数统计
     * @param genre
     * @return
     */
    @PostMapping("findOneBySixMonth")
    public Map findOneBySixMonth(@RequestParam("genre") String genre){
        Map map = new HashMap();
        Calendar calendar = Calendar.getInstance();
        long nowTome = calendar.getTime().getTime();

        // 1月前日期
        Date OneWeek1 = DateCuteUtil.getTimeByMonth(calendar,-1);
        Date OneWeek = DateCuteUtil.lastTime(OneWeek1);
        // 2月前日期
        Date TwoWeek1 = DateCuteUtil.getTimeByMonth(calendar,-2);
        Date TwoWeek = DateCuteUtil.lastTime(TwoWeek1);
        // 3月前日期
        Date ThreeWeek1 = DateCuteUtil.getTimeByMonth(calendar,-3);
        Date ThreeWeek = DateCuteUtil.lastTime(ThreeWeek1);
        // 4月前日期
        Date FourWeek1 = DateCuteUtil.getTimeByMonth(calendar,-4);
        Date FourWeek = DateCuteUtil.lastTime(FourWeek1);
        // 5月前日期
        Date FiveWeek1 = DateCuteUtil.getTimeByMonth(calendar,-5);
        Date FiveWeek = DateCuteUtil.lastTime(FiveWeek1);
        // 6月前日期
        Date SixWeek1 = DateCuteUtil.getTimeByMonth(calendar,-6);
        Date SixWeek = DateCuteUtil.lastTime(SixWeek1);

        // 第一段
        String seven_flag = fmt.format(SixWeek);
        List<Log> seven_log = logService.findAllByBeforeTime(FiveWeek.getTime(),SixWeek.getTime(),genre);
        // 第二段
        String eight_flag = fmt.format(FiveWeek);
        List<Log> eight_log = logService.findAllByBeforeTime(FourWeek.getTime(),FiveWeek.getTime(),genre);
        // 第三段
        String nine_flag = fmt.format(FourWeek);
        List<Log> nine_log = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),genre);
        // 第四段
        String ten_flag = fmt.format(ThreeWeek);
        List<Log> ten_log = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),genre);
        // 第五段
        String eleven_flag = fmt.format(TwoWeek);
        List<Log> eleven_log = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),genre);
        // 第六段
        String twelve_flag = fmt.format(OneWeek);
        List<Log> twelve_log = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),genre);

        map.put("1",seven_flag);
        map.put("2",eight_flag);
        map.put("3",nine_flag);
        map.put("4",ten_flag);
        map.put("5",eleven_flag);
        map.put("6",twelve_flag);
        map.put("7",seven_log.size());
        map.put("8",eight_log.size());
        map.put("9",nine_log.size());
        map.put("10",ten_log.size());
        map.put("11",eleven_log.size());
        map.put("12",twelve_log.size());

        return map;
    }

    /**
     * 近6个月内3种请求的次数统计
     * @return
     */
    @PostMapping("findThreeBySixMonth")
    public Map findThreeBySixMonth(){
        Map map = new HashMap();
        Calendar calendar = Calendar.getInstance();
        long nowTome = calendar.getTime().getTime();

        // 1月前日期
        Date OneWeek1 = DateCuteUtil.getTimeByMonth(calendar,-1);
        Date OneWeek = DateCuteUtil.lastTime(OneWeek1);
        // 2月前日期
        Date TwoWeek1 = DateCuteUtil.getTimeByMonth(calendar,-2);
        Date TwoWeek = DateCuteUtil.lastTime(TwoWeek1);
        // 3月前日期
        Date ThreeWeek1 = DateCuteUtil.getTimeByMonth(calendar,-3);
        Date ThreeWeek = DateCuteUtil.lastTime(ThreeWeek1);
        // 4月前日期
        Date FourWeek1 = DateCuteUtil.getTimeByMonth(calendar,-4);
        Date FourWeek = DateCuteUtil.lastTime(FourWeek1);
        // 5月前日期
        Date FiveWeek1 = DateCuteUtil.getTimeByMonth(calendar,-5);
        Date FiveWeek = DateCuteUtil.lastTime(FiveWeek1);
        // 6月前日期
        Date SixWeek1 = DateCuteUtil.getTimeByMonth(calendar,-6);
        Date SixWeek = DateCuteUtil.lastTime(SixWeek1);

        // 第一段
        String seven_flag = fmt.format(SixWeek);
        List<Log> seven_log0 = logService.findAllByBeforeTime(FiveWeek.getTime(),SixWeek.getTime(),"0");
        List<Log> seven_log1 = logService.findAllByBeforeTime(FiveWeek.getTime(),SixWeek.getTime(),"1");
        List<Log> seven_log2 = logService.findAllByBeforeTime(FiveWeek.getTime(),SixWeek.getTime(),"2");
        List list7 = new ArrayList();
        list7.add(seven_log0.size());
        list7.add(seven_log1.size());
        list7.add(seven_log2.size());
        // 第二段
        String eight_flag = fmt.format(FiveWeek);
        List<Log> eight_log0 = logService.findAllByBeforeTime(FourWeek.getTime(),FiveWeek.getTime(),"0");
        List<Log> eight_log1 = logService.findAllByBeforeTime(FourWeek.getTime(),FiveWeek.getTime(),"1");
        List<Log> eight_log2 = logService.findAllByBeforeTime(FourWeek.getTime(),FiveWeek.getTime(),"2");
        List list8 = new ArrayList();
        list8.add(eight_log0.size());
        list8.add(eight_log1.size());
        list8.add(eight_log2.size());
        // 第三段
        String nine_flag = fmt.format(FourWeek);
        List<Log> nine_log0 = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),"0");
        List<Log> nine_log1 = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),"1");
        List<Log> nine_log2 = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),"2");
        List list9 = new ArrayList();
        list9.add(nine_log0.size());
        list9.add(nine_log1.size());
        list9.add(nine_log2.size());
        // 第四段
        String ten_flag = fmt.format(ThreeWeek);
        List<Log> ten_log0 = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),"0");
        List<Log> ten_log1 = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),"1");
        List<Log> ten_log2 = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),"2");
        List list10 = new ArrayList();
        list10.add(ten_log0.size());
        list10.add(ten_log1.size());
        list10.add(ten_log2.size());
        // 第五段
        String eleven_flag = fmt.format(TwoWeek);
        List<Log> eleven_log0 = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),"0");
        List<Log> eleven_log1 = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),"1");
        List<Log> eleven_log2 = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),"2");
        List list11 = new ArrayList();
        list11.add(eleven_log0.size());
        list11.add(eleven_log1.size());
        list11.add(eleven_log2.size());
        // 第六段
        String twelve_flag = fmt.format(OneWeek);
        List<Log> twelve_log0 = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),"0");
        List<Log> twelve_log1 = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),"1");
        List<Log> twelve_log2 = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),"2");
        List list12 = new ArrayList();
        list12.add(twelve_log0.size());
        list12.add(twelve_log1.size());
        list12.add(twelve_log2.size());

        map.put("1",seven_flag);
        map.put("2",eight_flag);
        map.put("3",nine_flag);
        map.put("4",ten_flag);
        map.put("5",eleven_flag);
        map.put("6",twelve_flag);
        map.put("7",list7);
        map.put("8",list8);
        map.put("9",list9);
        map.put("10",list10);
        map.put("11",list11);
        map.put("12",list12);

        return map;
    }

    /**
     * 近1年内某一请求的次数统计
     * @param genre
     * @return
     */
    @PostMapping("findOneByOneYear")
    public Map findOneByOneYear(@RequestParam("genre") String genre){
        Map map = new HashMap();
        Calendar calendar = Calendar.getInstance();
        long nowTome = calendar.getTime().getTime();

        // 1前日期
        Date OneWeek1 = DateCuteUtil.getTimeByMonth(calendar,-1);
        Date OneWeek = DateCuteUtil.lastTime(OneWeek1);
        // 2前日期
        Date TwoWeek1 = DateCuteUtil.getTimeByMonth(calendar,-2);
        Date TwoWeek = DateCuteUtil.lastTime(TwoWeek1);
        // 3前日期
        Date ThreeWeek1 = DateCuteUtil.getTimeByMonth(calendar,-3);
        Date ThreeWeek = DateCuteUtil.lastTime(ThreeWeek1);
        // 4前日期
        Date FourWeek1 = DateCuteUtil.getTimeByMonth(calendar,-4);
        Date FourWeek = DateCuteUtil.lastTime(FourWeek1);
        // 5前日期
        Date FiveWeek1 = DateCuteUtil.getTimeByMonth(calendar,-5);
        Date FiveWeek = DateCuteUtil.lastTime(FiveWeek1);
        // 6前日期
        Date SixWeek1 = DateCuteUtil.getTimeByMonth(calendar,-6);
        Date SixWeek = DateCuteUtil.lastTime(SixWeek1);
        // 7前日期
        Date SevenWeek1 = DateCuteUtil.getTimeByMonth(calendar,-7);
        Date SevenWeek = DateCuteUtil.lastTime(SevenWeek1);
        // 8前日期
        Date EightWeek1 = DateCuteUtil.getTimeByMonth(calendar,-8);
        Date EightWeek = DateCuteUtil.lastTime(EightWeek1);
        // 9前日期
        Date NineWeek1 = DateCuteUtil.getTimeByMonth(calendar,-9);
        Date NineWeek = DateCuteUtil.lastTime(NineWeek1);
        // 10前日期
        Date TenWeek1 = DateCuteUtil.getTimeByMonth(calendar,-10);
        Date TenWeek = DateCuteUtil.lastTime(TenWeek1);
        // 11前日期
        Date ElevenWeek1 = DateCuteUtil.getTimeByMonth(calendar,-11);
        Date ElevenWeek = DateCuteUtil.lastTime(ElevenWeek1);
        // 12前日期
        Date TwelveWeek1 = DateCuteUtil.getTimeByMonth(calendar,-12);
        Date TwelveWeek = DateCuteUtil.lastTime(TwelveWeek1);

        // 第一段
        String one_flag = fmt.format(TwelveWeek);
        List<Log> one_log = logService.findAllByBeforeTime(ElevenWeek.getTime(),TwelveWeek.getTime(),genre);
        // 第二段
        String two_flag = fmt.format(ElevenWeek);
        List<Log> two_log = logService.findAllByBeforeTime(TenWeek.getTime(),ElevenWeek.getTime(),genre);
        // 第三段
        String three_flag = fmt.format(TenWeek);
        List<Log> three_log = logService.findAllByBeforeTime(NineWeek.getTime(),TenWeek.getTime(),genre);
        // 第四段
        String four_flag = fmt.format(NineWeek);
        List<Log> four_log = logService.findAllByBeforeTime(EightWeek.getTime(),NineWeek.getTime(),genre);
        // 第五段
        String five_flag = fmt.format(EightWeek);
        List<Log> five_log = logService.findAllByBeforeTime(SevenWeek.getTime(),EightWeek.getTime(),genre);
        // 第六段
        String six_flag = fmt.format(SevenWeek);
        List<Log> six_log = logService.findAllByBeforeTime(SixWeek.getTime(),SevenWeek.getTime(),genre);
        // 第七段
        String seven_flag = fmt.format(SixWeek);
        List<Log> seven_log = logService.findAllByBeforeTime(FiveWeek.getTime(),SixWeek.getTime(),genre);
        // 第八段
        String eight_flag = fmt.format(FiveWeek);
        List<Log> eight_log = logService.findAllByBeforeTime(FourWeek.getTime(),FiveWeek.getTime(),genre);
        // 第九段
        String nine_flag = fmt.format(FourWeek);
        List<Log> nine_log = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),genre);
        // 第十段
        String ten_flag = fmt.format(ThreeWeek);
        List<Log> ten_log = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),genre);
        // 第十一段
        String eleven_flag = fmt.format(TwoWeek);
        List<Log> eleven_log = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),genre);
        // 第十二段
        String twelve_flag = fmt.format(OneWeek);
        List<Log> twelve_log = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),genre);

        map.put("1",one_flag);
        map.put("2",two_flag);
        map.put("3",three_flag);
        map.put("4",four_flag);
        map.put("5",five_flag);
        map.put("6",six_flag);
        map.put("7",seven_flag);
        map.put("8",eight_flag);
        map.put("9",nine_flag);
        map.put("10",ten_flag);
        map.put("11",eleven_flag);
        map.put("12",twelve_flag);
        map.put("13",one_log.size());
        map.put("14",two_log.size());
        map.put("15",three_log.size());
        map.put("16",four_log.size());
        map.put("17",five_log.size());
        map.put("18",six_log.size());
        map.put("19",seven_log.size());
        map.put("20",eight_log.size());
        map.put("21",nine_log.size());
        map.put("22",ten_log.size());
        map.put("23",eleven_log.size());
        map.put("24",twelve_log.size());

        return map;
    }

    /**
     * 近1年内3种请求的次数统计
     * @return
     */
    @PostMapping("findThreeByOneYear")
    public Map findThreeByOneYear(){
        Map map = new HashMap();
        Calendar calendar = Calendar.getInstance();
        long nowTome = calendar.getTime().getTime();

        // 1前日期
        Date OneWeek1 = DateCuteUtil.getTimeByMonth(calendar,-1);
        Date OneWeek = DateCuteUtil.lastTime(OneWeek1);
        // 2前日期
        Date TwoWeek1 = DateCuteUtil.getTimeByMonth(calendar,-2);
        Date TwoWeek = DateCuteUtil.lastTime(TwoWeek1);
        // 3前日期
        Date ThreeWeek1 = DateCuteUtil.getTimeByMonth(calendar,-3);
        Date ThreeWeek = DateCuteUtil.lastTime(ThreeWeek1);
        // 4前日期
        Date FourWeek1 = DateCuteUtil.getTimeByMonth(calendar,-4);
        Date FourWeek = DateCuteUtil.lastTime(FourWeek1);
        // 5前日期
        Date FiveWeek1 = DateCuteUtil.getTimeByMonth(calendar,-5);
        Date FiveWeek = DateCuteUtil.lastTime(FiveWeek1);
        // 6前日期
        Date SixWeek1 = DateCuteUtil.getTimeByMonth(calendar,-6);
        Date SixWeek = DateCuteUtil.lastTime(SixWeek1);
        // 7前日期
        Date SevenWeek1 = DateCuteUtil.getTimeByMonth(calendar,-7);
        Date SevenWeek = DateCuteUtil.lastTime(SevenWeek1);
        // 8前日期
        Date EightWeek1 = DateCuteUtil.getTimeByMonth(calendar,-8);
        Date EightWeek = DateCuteUtil.lastTime(EightWeek1);
        // 9前日期
        Date NineWeek1 = DateCuteUtil.getTimeByMonth(calendar,-9);
        Date NineWeek = DateCuteUtil.lastTime(NineWeek1);
        // 10前日期
        Date TenWeek1 = DateCuteUtil.getTimeByMonth(calendar,-10);
        Date TenWeek = DateCuteUtil.lastTime(TenWeek1);
        // 11前日期
        Date ElevenWeek1 = DateCuteUtil.getTimeByMonth(calendar,-11);
        Date ElevenWeek = DateCuteUtil.lastTime(ElevenWeek1);
        // 12前日期
        Date TwelveWeek1 = DateCuteUtil.getTimeByMonth(calendar,-12);
        Date TwelveWeek = DateCuteUtil.lastTime(TwelveWeek1);

        // 第一段
        String one_flag = fmt.format(TwelveWeek);
        List<Log> one_log0 = logService.findAllByBeforeTime(ElevenWeek.getTime(),TwelveWeek.getTime(),"0");
        List<Log> one_log1 = logService.findAllByBeforeTime(ElevenWeek.getTime(),TwelveWeek.getTime(),"1");
        List<Log> one_log2 = logService.findAllByBeforeTime(ElevenWeek.getTime(),TwelveWeek.getTime(),"2");
        List list1 = new ArrayList();
        list1.add(one_log0.size());
        list1.add(one_log1.size());
        list1.add(one_log2.size());
        // 第二段
        String two_flag = fmt.format(ElevenWeek);
        List<Log> two_log0 = logService.findAllByBeforeTime(TenWeek.getTime(),ElevenWeek.getTime(),"0");
        List<Log> two_log1 = logService.findAllByBeforeTime(TenWeek.getTime(),ElevenWeek.getTime(),"1");
        List<Log> two_log2 = logService.findAllByBeforeTime(TenWeek.getTime(),ElevenWeek.getTime(),"2");
        List list2 = new ArrayList();
        list2.add(two_log0.size());
        list2.add(two_log1.size());
        list2.add(two_log2.size());
        // 第三段
        String three_flag = fmt.format(TenWeek);
        List<Log> three_log0 = logService.findAllByBeforeTime(NineWeek.getTime(),TenWeek.getTime(),"0");
        List<Log> three_log1 = logService.findAllByBeforeTime(NineWeek.getTime(),TenWeek.getTime(),"1");
        List<Log> three_log2 = logService.findAllByBeforeTime(NineWeek.getTime(),TenWeek.getTime(),"2");
        List list3 = new ArrayList();
        list3.add(three_log0.size());
        list3.add(three_log1.size());
        list3.add(three_log2.size());
        // 第四段
        String four_flag = fmt.format(NineWeek);
        List<Log> four_log0 = logService.findAllByBeforeTime(EightWeek.getTime(),NineWeek.getTime(),"0");
        List<Log> four_log1 = logService.findAllByBeforeTime(EightWeek.getTime(),NineWeek.getTime(),"1");
        List<Log> four_log2 = logService.findAllByBeforeTime(EightWeek.getTime(),NineWeek.getTime(),"2");
        List list4 = new ArrayList();
        list4.add(four_log0.size());
        list4.add(four_log1.size());
        list4.add(four_log2.size());
        // 第五段
        String five_flag = fmt.format(EightWeek);
        List<Log> five_log0 = logService.findAllByBeforeTime(SevenWeek.getTime(),EightWeek.getTime(),"0");
        List<Log> five_log1 = logService.findAllByBeforeTime(SevenWeek.getTime(),EightWeek.getTime(),"1");
        List<Log> five_log2 = logService.findAllByBeforeTime(SevenWeek.getTime(),EightWeek.getTime(),"2");
        List list5 = new ArrayList();
        list5.add(five_log0.size());
        list5.add(five_log1.size());
        list5.add(five_log2.size());
        // 第六段
        String six_flag = fmt.format(SevenWeek);
        List<Log> six_log0 = logService.findAllByBeforeTime(SixWeek.getTime(),SevenWeek.getTime(),"0");
        List<Log> six_log1 = logService.findAllByBeforeTime(SixWeek.getTime(),SevenWeek.getTime(),"1");
        List<Log> six_log2 = logService.findAllByBeforeTime(SixWeek.getTime(),SevenWeek.getTime(),"2");
        List list6 = new ArrayList();
        list6.add(six_log0.size());
        list6.add(six_log1.size());
        list6.add(six_log2.size());
        // 第七段
        String seven_flag = fmt.format(SixWeek);
        List<Log> seven_log0 = logService.findAllByBeforeTime(FiveWeek.getTime(),SixWeek.getTime(),"0");
        List<Log> seven_log1 = logService.findAllByBeforeTime(FiveWeek.getTime(),SixWeek.getTime(),"1");
        List<Log> seven_log2 = logService.findAllByBeforeTime(FiveWeek.getTime(),SixWeek.getTime(),"2");
        List list7 = new ArrayList();
        list7.add(seven_log0.size());
        list7.add(seven_log1.size());
        list7.add(seven_log2.size());
        // 第八段
        String eight_flag = fmt.format(FiveWeek);
        List<Log> eight_log0 = logService.findAllByBeforeTime(FourWeek.getTime(),FiveWeek.getTime(),"0");
        List<Log> eight_log1 = logService.findAllByBeforeTime(FourWeek.getTime(),FiveWeek.getTime(),"1");
        List<Log> eight_log2 = logService.findAllByBeforeTime(FourWeek.getTime(),FiveWeek.getTime(),"2");
        List list8 = new ArrayList();
        list8.add(eight_log0.size());
        list8.add(eight_log1.size());
        list8.add(eight_log2.size());
        // 第九段
        String nine_flag = fmt.format(FourWeek);
        List<Log> nine_log0 = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),"0");
        List<Log> nine_log1 = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),"1");
        List<Log> nine_log2 = logService.findAllByBeforeTime(ThreeWeek.getTime(),FourWeek.getTime(),"2");
        List list9 = new ArrayList();
        list9.add(nine_log0.size());
        list9.add(nine_log1.size());
        list9.add(nine_log2.size());
        // 第十段
        String ten_flag = fmt.format(ThreeWeek);
        List<Log> ten_log0 = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),"0");
        List<Log> ten_log1 = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),"1");
        List<Log> ten_log2 = logService.findAllByBeforeTime(TwoWeek.getTime(),ThreeWeek.getTime(),"2");
        List list10 = new ArrayList();
        list10.add(ten_log0.size());
        list10.add(ten_log1.size());
        list10.add(ten_log2.size());
        // 第十一段
        String eleven_flag = fmt.format(TwoWeek);
        List<Log> eleven_log0 = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),"0");
        List<Log> eleven_log1 = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),"1");
        List<Log> eleven_log2 = logService.findAllByBeforeTime(OneWeek.getTime(),TwoWeek.getTime(),"2");
        List list11 = new ArrayList();
        list11.add(eleven_log0.size());
        list11.add(eleven_log1.size());
        list11.add(eleven_log2.size());
        // 第十二段
        String twelve_flag = fmt.format(OneWeek);
        List<Log> twelve_log0 = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),"0");
        List<Log> twelve_log1 = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),"1");
        List<Log> twelve_log2 = logService.findAllByBeforeTime(nowTome,OneWeek.getTime(),"2");
        List list12 = new ArrayList();
        list12.add(twelve_log0.size());
        list12.add(twelve_log1.size());
        list12.add(twelve_log2.size());

        map.put("1",one_flag);
        map.put("2",two_flag);
        map.put("3",three_flag);
        map.put("4",four_flag);
        map.put("5",five_flag);
        map.put("6",six_flag);
        map.put("7",seven_flag);
        map.put("8",eight_flag);
        map.put("9",nine_flag);
        map.put("10",ten_flag);
        map.put("11",eleven_flag);
        map.put("12",twelve_flag);
        map.put("13",list1);
        map.put("14",list2);
        map.put("15",list3);
        map.put("16",list4);
        map.put("17",list5);
        map.put("18",list6);
        map.put("19",list7);
        map.put("20",list8);
        map.put("21",list9);
        map.put("22",list10);
        map.put("23",list11);
        map.put("24",list12);

        return map;
    }

//    public Map findByEveryMoth(){
//
//    }

}
